package com.le.tester.leetcode;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;

/**
 * currentTime:2022/3/11 16:32
 * description:存在重复的元素
 */
public class ContainsDuplicate {
    public boolean containsDuplicate(int[] nums) {
        int targetLen = nums.length;
//        Map<Object, Object> targetMap = new HashMap<>();
        HashSet<Integer> targetSet = new HashSet<>();
        for (int num : nums) {
//            targetMap.put(nums[i], i);
            targetSet.add(num);
        }
        return targetLen != targetSet.size();
    }

    public static void main(String[] args) {
        ContainsDuplicate containsDuplicate = new ContainsDuplicate();
        int[] tempArr = new int[]{1, 1, 1, 3, 3, 4, 3, 2, 4, 2};
        System.out.println(containsDuplicate.containsDuplicate(tempArr));
    }
}
